package com.hujf.netty.inandoutboundhandler;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;

/**
 * @author Hujf
 * @title: MyServerInit
 * @date 2021/2/6 0006上午 9:18
 * @description: TODO
 */
public class MyServerInitializer extends ChannelInitializer<SocketChannel> {
    @Override
    protected void initChannel(SocketChannel ch) throws Exception {
        ChannelPipeline pipeline = ch.pipeline();

        //作为服务器  需要一个解码 接收
        pipeline.addLast(new MyByteToLongDecoder2());

        //作为服务器  需要一个编码  发送出去
        pipeline.addLast(new MyLongToByteEncoder());
        //业务处理
        pipeline.addLast(new MyServerHandler());

    }
}
